package com.cskaoyan.dbutils.resultsethandler;

import com.cskaoyan.dbutils.Account;
import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;

public class MyResultSetHandler implements ResultSetHandler<Account> {
    // 把ResultSet结果集解析成 Account对象
    @Override
    public Account handle(ResultSet resultSet) throws SQLException {
        Account account = new Account();
        if (resultSet.next()) {

            int id = resultSet.getInt("id");
            String name = resultSet.getString("name");
            int money = resultSet.getInt("money");

            account.setId(id);
            account.setName(name);
            account.setMoney(money);
        }
        return account;
    }
}
